package store.lunangangster.engine.impl.bpmn.behavior;

import store.lunangangster.engine.NodeFlowException;
import store.lunangangster.engine.impl.entity.ExecutionEntity;

public abstract class FlowNodeBehavior implements TriggerableModelBehavior {

  protected BpmnBehaviorHelper bpmnBehaviorHelper = new BpmnBehaviorHelper();

  @Override
  public void doBehavior(ExecutionEntity execution) {
    goNext(execution);
  }

  /**
   * 所有FlowNode的默认行为：计算OutGoingSequenceFlow的条件表达式，从而选择合适的路径
   * @param execution FlowNode的动态表示
   */
  public void goNext(ExecutionEntity execution) {
    bpmnBehaviorHelper.doDefaultOutGoingBehavior(execution);
  }


  @Override
  public void trigger(ExecutionEntity execution) {
    // 所有需要接收信号的FlowNodeBehavior都需要重写该方法
    throw new NodeFlowException("该FlowNode不触发任何信号");
  }
}
